import { QXEvent } from "qx-util";
import { IParam, ReportPanelActionType, IReportPanelAbility, IReportPanelControllerParams, IReportPanelStore, ReportPanelController, ICtrlEvent, IReportPanelController, IReportPanelModel } from "@/core";
import { useReportPanelAction, useReportPanelBasic, useReportPanelControllerParams, useReportPanelProps } from "@/hooks/widget/use-report-panel";
import { ReportpanelControlVO } from './report-report-panel-vo';
import { model } from "./report-report-panel-model";
import ReportPanelService from "@/core/modules/ctrl-service/report-panel-service";
// 基于template/src/widgets/{{appEntities}}/{{ctrls@REPORTPANEL}}-report-panel/{{spinalCase ctrl.codeName}}-report-panel-hook.ts.hbs生成
/**
 * 获取输入参数
 *
 * @export
 * @return {*}
 */
export function useProps() {
	return {
		...useReportPanelProps(),
	};
}

/**
 * 获取基础数据
 *
 * @export
 * @param {*} props
 * @return {*}
 */
export function useBasic(props: any) {
	return {
		...useReportPanelBasic(model, props),
	};
}

/**
 * 获取行为
 *
 * @export
 */
export function useAction(controller: any) {
	return {
		...useReportPanelAction(controller),
	};
}

/**
 * 获取控制器
 *
 * @export
 * @param {IParam} props
 * @param {QXEvent<ICtrlEvent<ReportPanelActionType, IReportPanelAbility>>} evt
 * @return {*}
 */
export function useController(
	props: IParam,
	evt: QXEvent<ICtrlEvent<ReportPanelActionType, IReportPanelAbility>>,
    otherParams: IParam = {},
): IReportPanelController<IReportPanelStore, IReportPanelAbility> {
	const params: IReportPanelControllerParams<ReportPanelActionType, IReportPanelAbility> =
		useReportPanelControllerParams<IReportPanelStore, IReportPanelModel>(model, props, evt, otherParams);
    const ctrlService = new ReportPanelService<ReportpanelControlVO>(ReportpanelControlVO, model.entityCodeName, otherParams.attrs);
  	Object.assign(params, { ctrlService });
  	return new ReportPanelController(params);
}